﻿using SeeSharpTools.JY.GUI;
using Sunny.UI;
using System;

namespace SeeSharpTools.Demo.GUI
{
    public partial class FormNumeric : UIPage
    {
        private bool[] ledArrayValue1;
        private bool[] ledArrayValue2;

        public FormNumeric()
        {
            InitializeComponent();

            buttonSwitch1.Value = true;
            ledBright1.BlinkOn = true;

            ledArray1.ControlHeight = 30;
            ledArray1.ControlWidth = 30;
            ledArray2.ControlHeight = 30;
            ledArray2.ControlWidth = 30;
            switchArray1.ControlHeight = 30;
            switchArray1.ControlWidth = 30;
            switchArray2.ControlHeight = 30;
            switchArray2.ControlWidth = 30;
            buttonSwitchArray1.ControlHeight = 25;
            buttonSwitchArray1.ControlWidth = 55;
            buttonSwitchArray2.ControlHeight = 25;
            buttonSwitchArray2.ControlWidth = 55;
        }

        private void switchArray1_ControlValueChanged(object sender, SeeSharpTools.JY.GUI.SwitchArray.ValueChangedEventArgs e)
        {
            ledArray1.Value = switchArray1.Value;
        }

        private void switchArray2_ControlValueChanged(object sender, SeeSharpTools.JY.GUI.SwitchArray.ValueChangedEventArgs e)
        {
            ledArray2.Value = switchArray2.Value;
        }

        private void buttonSwitch1_ValueChanged(object sender, EventArgs e)
        {
            ledArrayValue1 = new bool[] { buttonSwitch1.Value, buttonSwitch2.Value, buttonSwitch3.Value, buttonSwitch4.Value };
            ledArray1.Value = ledArrayValue1;
            if (buttonSwitch1.Value == true && buttonSwitch2.Value == true && buttonSwitch3.Value == true && buttonSwitch4.Value == true)
            {
                led1.BlinkOn = true;
                led1.BlinkInterval = 200;
            }
            else
            {
                led1.BlinkOn = false;
            }
        }

        private void buttonSwitch5_ValueChanged(object sender, EventArgs e)
        {
            ledArrayValue2 = new bool[] { buttonSwitch5.Value, buttonSwitch6.Value, buttonSwitch7.Value, buttonSwitch8.Value };
            ledArray2.Value = ledArrayValue2;
            if (buttonSwitch5.Value == true && buttonSwitch6.Value == true && buttonSwitch7.Value == true && buttonSwitch8.Value == true)
            {
                ledBright1.BlinkOn = true;
                ledBright1.BlinkInterval = 200;
            }
            else
            {
                ledBright1.BlinkOn = false;
            }
        }
    }
}